package com.gift.recommendation.modules.admin.controller;

import com.gift.recommendation.Base.BaseResponse;
import com.gift.recommendation.config.TokenPass;
import com.gift.recommendation.modules.admin.biz.PictureImpl;
import com.gift.recommendation.modules.admin.dto.NoticeReleaseAddReq;
import com.gift.recommendation.modules.admin.dto.PictureReq;
import com.gift.recommendation.modules.admin.dto.PictureRsp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author zzh <2658137258@qq.com>
 * @date 2023/2/20
 */
@RestController
@RequestMapping("/gift/picture")
@Api(tags = "图片管理")
@Validated
public class PictureController {

    @Autowired
    private PictureImpl picture;

    @ApiOperation(value = "上传图片")
    @RequestMapping(path = "/upload",method = RequestMethod.POST)
    @TokenPass
    public BaseResponse upload(@RequestParam("picture") MultipartFile multipartFile){
        PictureRsp pictureRsp = picture.upload(multipartFile);
        return BaseResponse.success(pictureRsp);
    };

    @ApiOperation(value = "删除图片")
    @RequestMapping(path = "/delete",method = RequestMethod.POST)
    @TokenPass
    public BaseResponse delete(@RequestBody PictureReq req){
         picture.delete(req);
        return BaseResponse.success();
    };
}
